<template>
  <div class="navigation-container">
    <el-menu
      :default-active="activeIndex"
      class="navigation-menu"
      mode="horizontal"
      router
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
    >
      <el-menu-item index="/">
        <el-icon><House /></el-icon>
        <span>首页</span>
      </el-menu-item>
      
              <el-menu-item index="/workout-plan">
          <el-icon><StarFilled /></el-icon>
          <span>AI训练计划</span>
        </el-menu-item>
      
      <el-menu-item index="/user-profile">
        <el-icon><User /></el-icon>
        <span>个人资料</span>
      </el-menu-item>
      
      <el-menu-item index="/ai-medal">
        <el-icon><Trophy /></el-icon>
        <span>AI勋章</span>
      </el-menu-item>
      
      <el-menu-item 
        v-if="verifyStatus !== '1'" 
        index="/idcard-verification"
      >
        <el-icon><Document /></el-icon>
        <span>实名认证</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { House, StarFilled, User, Trophy, Document } from '@element-plus/icons-vue'
import { authAPI } from '@/api/index'

const route = useRoute()
const activeIndex = ref('/')
const verifyStatus = ref('0')

// 获取认证状态
const getVerifyStatus = async () => {
  try {
    const response = await authAPI.getIdCardStatus()
    if (response && response.data && response.data.success) {
      verifyStatus.value = response.data.data.verify_status
    }
  } catch (error) {
    console.error('获取认证状态失败:', error)
  }
}

onMounted(() => {
  activeIndex.value = route.path
  getVerifyStatus()
})
</script>

<style scoped>
.navigation-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background-color: #545c64;
}

.navigation-menu {
  max-width: 1200px;
  margin: 0 auto;
}

.el-menu-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .navigation-menu {
    padding: 0 10px;
  }
  
  .el-menu-item span {
    display: none;
  }
}
</style>
